//数据渲染

// const { data } = require("jquery")

class listKB {
    constructor() {
        this.container = $('.KBul')[0]
        // this.span=$('span')
        this.init()
    }
    init() {
        this.request()
    }
    request() {
        pAjax({
            url: '/libs/data/goods.json'
        })
            .then((res) => {
                let dataKB = JSON.parse(res)
                dataKB = dataKB.slice(94, 99)
                this.render(dataKB)
                console.log(dataKB)
            })
    }
    render(dataKB) {
        dataKB.forEach(item => {
            this.container.innerHTML += `
                        <li><a href="#">
                        <div class="mask-img">
                            <img src="${item.img_small_logo}">
                        </div>
                        <p class="mask-title">${item.title}</p>
                        <p class="mask-des">${item.price}</p>
                    </a></li>
                    `
            }
        )
    }

}
new listKB()


class listMain{
    constructor() {
        this.container = $('.goods-data')[0]
       
        this.init()
    }
    init() {
        this.request()
        
    }
    request() {
        pAjax({
            url: '/libs/data/goods.json'
        })
            .then((res) => {
                let dataGoods = JSON.parse(res)
                dataGoods = dataGoods.slice(180, 230)
                console.log(dataGoods)
                this.render(dataGoods)
                // this.mainClick(dataGoods)
            })
    }
    render(dataGoods) {
        dataGoods.forEach(item => {
            this.container.innerHTML += `
                        <li><a href="http://127.0.0.1:2113/html/data.html?id=${item.goods_id}">
                        <div class="goods-img">
                            <img src="${item.img_small_logo}">
                        </div>
                        <p class="mask-title">${item.title}</p>
                        <p class="mask-des"><span class="span-red">￥${item.price}</spam></p>
                    </a></li>
                    `
            }
        )

    }
   
}
new listMain()

